package receiver;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ita.ios.jms.protocol.JmsProtocol;

import po.DishAudit;
import service.DishAuditManager;
import vo.DishAuditVo;
import vo.MerchantAuditVo;

 
@Component("dishAdListener")
public class DishAdListener implements MessageListener {
	
	@Autowired
	private DishAuditManager dishAuditManager;
	
	@Override
	public void onMessage(Message message) {
		try {
			String text = ((TextMessage)message).getText();
			System.out.println("dishAdListener接收到消息:" + text);
			DishAudit dishAudit = (DishAudit) JmsProtocol.deserializeObject(text, DishAudit.class);
			if(dishAudit != null){
				dishAuditManager.addDishAudit(dishAudit);
				System.out.println("add the dishAudit success!!!");
			}
			} catch (JMSException e) {
				e.printStackTrace();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
}
